*cd "/Users/sanchariroy/Google Drive/Sanchari_F/DBW/data/prepared_data/"
*cd "/Users/bsog0079/Dropbox/DBW/agencytrainingpaper/ReSTAT_revisions/prepared_data"
cd "/Users/sr432/Google Drive/Sanchari_F/DBW/data/prepared_data_dropbox/"


use medium_term_savings_data, clear

set more off

/*** This do file contains the code for the following Tables:
Main Tables: 7
Appendix Tables: A13, A21
***/

********************************************************************************
***REGRESSIONS: MEDIUM TERM SAVINGS IMPACT**************************************
********************************************************************************

global controls age edu muslim babu_bline contrdum1_bline contrdum3_bline memdurb_bline ushac_bline logmthinc_bline

/**Table A13**/

eststo clear

eststo: reg switchtofuture treat areadum1, cl(hhid)
eststo: reg switchtofuture treat $controls areadum1, cl(hhid)

esttab using appendtables.rtf, append se title(Appendix Table A13: Program Impact on Switching Behaviour) cells(b(star fmt(2)) se(par fmt(2))) note("$treatnote1 $clusternote1 $controlnote") keep(treat) indicate("Area fixed effects = areadum*" "Controls = $controls") starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2_a N, fmt(2 0) label("Adj. R-sq" "N"))


/**Table 7**/


eststo clear

eststo reg1: reg acclosed_imm treat areadum1, cl(hhid)
ritest treat _b[treat], reps(1000) seed(125): `e(cmdline)'
matrix pvalues=r(p)
mat colnames pvalues = treat
est restore reg1
estadd matrix pvalues = pvalues

eststo reg2: reg acclosed_oneyron1 treat areadum1, cl(hhid)
ritest treat _b[treat], reps(1000) seed(125): `e(cmdline)'
matrix pvalues=r(p)
mat colnames pvalues = treat
est restore reg2
estadd matrix pvalues = pvalues

eststo reg3: reg acclosed treat areadum1, cl(hhid)
ritest treat _b[treat], reps(1000) seed(125): `e(cmdline)'
matrix pvalues=r(p)
mat colnames pvalues = treat
est restore reg3
estadd matrix pvalues = pvalues

esttab using maintables.rtf, append se title(Table 7: Program Impact on Account Closures and Final Balances) cells(b(star fmt(2)) se(par fmt(2)) pvalues(par([ ]))) keep(treat) label indicate("Area fixed effects = areadum*") starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2_a N, fmt(2 0) label("Adj. R-sq" "N"))


/**Table 7 cont'd**/

eststo clear

eststo reg1: reg finalbal3 treat areadum1, cl(hhid)
ritest treat _b[treat], reps(1000) seed(125): `e(cmdline)'
matrix pvalues=r(p)
mat colnames pvalues = treat
est restore reg1
estadd matrix pvalues = pvalues

esttab using maintables.rtf, append se title(Table 7: Program Impact on Account Closures and Final Balances) cells(b(star fmt(2)) se(par fmt(2)) pvalues(par([ ]))) keep(treat) label indicate("Area fixed effects = areadum*") starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2_a N, fmt(2 0) label("Adj. R-sq" "N"))


/**Appendix Table A21**/

eststo clear

eststo: reg acclosed treat areadum1 if fixedac==1, cl(hhid)
eststo: reg acclosed treat areadum1 if acclosed_imm==0&acclosed_oneyron==0&fixedac==1, cl(hhid)
eststo: reg acclosed treat areadum1 if fixedac==0, cl(hhid)
eststo: reg acclosed treat areadum1 if acclosed_imm==0&acclosed_oneyron==0&fixedac==0, cl(hhid)

esttab using appendtables.rtf, append se title(Appendix Table A21: Program Impact on Account Closures 15 months After Program, by Account Type) note("$treatnote1 $clusternote1") cells(b(star fmt(2)) se(par fmt(2))) keep(treat) label indicate("Area fixed effects = areadum*") starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2_a N, fmt(2 0) label("Adj. R-sq" "N"))


